Repository navigation
refactor(tree_sitter): let Tree own the source and positions so nodes borrow it and trees are Send - #35
Merged
Conversation
… borrow it and trees are Send
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
tree_sitterモジュールのTree/Node/TreeCursorは、位置情報の表をRc<HashMap<TextRange, Range>>で共有していました。そのためSendではなく、パースしたツリーを持ったまま.awaitをまたぐことや、別スレッドへ渡すことができませんでした。この PR では
Treeがソース・ルート・位置情報の表を所有し、Nodeは&Treeを借用する形に変えます。これでTree/Node/TreeCursorはすべてSend + Syncになります。変更内容
Treeがsrc・root・range_mapを所有するNode<'a>は{ tree: &'a Tree, node_or_token }だけを持つCopy型にする(clone のコストが無くなる)Node::is_token()Tree::source()TreeCursor::source()as_tree_sitter_cursorを削除する影響
crates/postgresql-cst-parser/src/tree_sitter.rsだけです。.clone()を消すことと、フィールドへの直接アクセスをアクセサに置き換えることが必要になります。確認
Tree/Node/TreeCursorがSend + Syncであること(コンパイル時のアサーションで確認)